#include "CNewsCellTableWidget.h"

CNewsCellTableWidget::CNewsCellTableWidget(QWidget* parent) : QWidget(parent), ui(new Ui::CNewsCellTableWidgetClass())
{
	ui->setupUi(this);
	m_pTableWidget = new QTableWidget(this);
	m_pTableWidget->setGeometry(0, 0, 530, 1000);
	m_pTableWidget->horizontalHeader()->setHidden(true);
	m_pTableWidget->verticalHeader()->setHidden(true);
	m_pTableWidget->setColumnCount(1);
	m_pTableWidget->horizontalHeader()->setDefaultSectionSize(500);
	m_pTableWidget->verticalHeader()->setDefaultSectionSize(160);
	m_pTableWidget->setStyleSheet("QTableWidget::item:selected{background-color: transparent;}");
}

CNewsCellTableWidget::~CNewsCellTableWidget()
{
	delete ui;
}

void CNewsCellTableWidget::SetUi(const QVector<CNewsCellData*>& kqVt, const QObject* kpMiniApp)
{
	int n = kqVt.size();
	m_pTableWidget->setRowCount(n);
	for (int i = 0; i < n; i++)
	{
		CNewsCellWidget* pNewsCellWidget = new CNewsCellWidget;
		pNewsCellWidget->SetUi(kqVt[i]);
		connect(pNewsCellWidget, SIGNAL(NewsCellClick(CNewsCellData*)), kpMiniApp, SLOT(OnNewsCellClick(CNewsCellData*)));
		m_pTableWidget->setCellWidget(i, 0, pNewsCellWidget);
	}
}